//该文件专门创建整个应用的路由器
// import VueRouter from 'vue-router'
import Vue from 'vue'
import Router from 'vue-router'

import layout from '@/layout'
Vue.use(Router)

import company from './modules/company'
import systemManagement from './modules/systemManagement'

export const constantRoutes = [
  // 首页
  {
    path: '/login',
    component: () => import('../views/login/index.vue')
  },
  {
    path: '/',
    component: layout,
    redirect: '/generalInformation',
    meta: {
      title: '企业管理'
    },
    children: [
      {
        path: '/generalInformation',
        name: 'generalInformation',
        component: () => import('../views/company/generalInformation.vue'),
        meta: { title: '企业通用信息' }
      }
    ]
  }
  // {
  //   path: '/systemManagement',
  //   component: layout,
  //   redirect: '/menuManagement',
  //   meta: {
  //     title: '系统管理'
  //   },
  //   children: [
  //     {
  //       path: '/menuManagement',
  //       name: 'menuManagement',
  //       component: () => import('../views/systemManagement/menuManagement.vue'),
  //       meta: { title: '菜单管理' }
  //     },

  //     {
  //       path: '/roleManagement',
  //       name: 'roleManagement',
  //       component: () => import('../views/systemManagement/roleManagement.vue'),
  //       meta: { title: '角色管理' }
  //     },
  //     {
  //       path: '/accountManagement',
  //       name: 'accountManagement',
  //       component: () =>
  //         import('../views/systemManagement/accountManagement.vue'),
  //       meta: { title: '账号管理' }
  //     }
  //   ]
  // }
]

export const asyncRouter = [company, systemManagement]

const createRouter = () =>
  new Router({
    // mode: 'history', // require service support
    scrollBehavior: () => ({ y: 0 }),
    routes: constantRoutes
  })

const router = createRouter()

export function resetRouter () {
  const newRouter = createRouter()
  router.matcher = newRouter.matcher // reset router
}

export default router
